/** @odoo-module **/
import col from './col.js'
import GroupRowInnerRenderer from './GroupRowInnerRenderer.js'
// import CustomTooltip from './CustomTooltip.js'

// console.log(data());
const init_grid_options = () => {

    const gridOptions = {
        columnDefs: col(),
        rowHeight:32,
        rowData:[],
        defaultColDef: {
            editable: params => {
                if(params.data.edit == false){
                    return false
                }
                return true
            },//单元表格是否可编辑
            // enableRowGroup: true,
            // sortable: true, //开启排序
            resizable: true,//是否可以调整列大小，就是拖动改变列大小
            filter: true,  //开启刷选
            // filter: 'agTextColumnFilter',
            // flex:1,
            // tooltipComponent: CustomTooltip,
        },
        tooltipShowDelay: 0,
        tooltipHideDelay: 2000,

        suppressRowHoverHighlight:true,
        columnHoverHighlight:false,
        rowSelection: 'single', // 开启多行选择 multiple
        groupSelectsChildren: false,
        // suppressMenuHide:true,
        suppressRowClickSelection: false,
        suppressAggFuncInHeader: true,
        enableRangeSelection: true,
        enableRangeHandle: true,
        undoRedoCellEditing: true,
        // enterMovesDown: false,
        enterMovesDownAfterEdit: false,

        suppressCopyRowsToClipboard: true,
        rowMultiSelectWithClick: true,
        // suppressCellSelection: true,
        groupDisplayType: 'groupRows',
        // autoGroupColumnDef:{
        //     headerName:'分组别名',
        //     minWdith: 60,
        //     pinned: 'left',
        //     field: 'cl1',
        //     cellRendererParams: {
        //         suppressCount: true,
        //     }
        // },
        groupRowRendererParams: {
            suppressCount: true,
            innerRenderer: GroupRowInnerRenderer,
            editable:false
        },
        groupDefaultExpanded: -1,
        // getContextMenuItems:(e) => agGridApi.getContextMenuItems(e,gridOptions),
        // editType: 'fullRow',
        onGridReady: function (params) {
            //表格创建完成后执行的事件
            // console.log('1111111111111111111111')
            // this.api.sizeColumnsToFit();//调整表格大小自适应
        },
        undoRedoCellEditingLimit: 20,
        // onCellValueChanged: (e) => agGridApi.onCellValueChanged(e,gridOptions),
        // getRowStyle: params => agGridApi.getRowStyle(params),
        // onPasteStart: params => agGridApi.onPasteStart(params),
        // paginationAutoPageSize: true, //根据网页高度自动分页（前端分页）
        overlayNoRowsTemplate:'<span>暂无数据</span>',
        getRowId: (params) => {
            // the code is unique, so perfect for the id
            return params.data.id;
        }
    };

    return gridOptions;


}


export default init_grid_options
